package com.str.algorithm;
public class LargestValue {
	
	public static int largest1(int[] array, int n) {
        int currLarge = 0;
        for (int i = 1; i < n; i++)
            if (array[currLarge] < array[i])
                currLarge = i;
        return currLarge;
    }

	public static int largest2(int[] array, int n) {
        if (n == 1) return 0;
        // else 
        int currLarge = largest2(array, n-1); 
        return (array[currLarge] > array[n-1]) ? currLarge : n-1;
    }

    public static void main(String[] args) {

 		final int NUM = 10;
        int[] a = new int[NUM];
        for (int i=0; i<NUM; i++)
            a[i] = (int) (Math.random() * 100);
        for (int i = 0; i < NUM; i++)
            System.out.print(a[i] + "  ");
        System.out.println();
        int max1 = largest1(a, NUM);
        int max2 = largest2(a, NUM);
        System.out.println("The largest value position is " + max1 + "  " + max2);
        System.out.println("The value is " + a[max1] + "  " + a[max2]);
    }
}
